<?php

	// +----------------------------------------------------------------------
	// | 加载首页数据
	// +----------------------------------------------------------------------
	// | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
	// +----------------------------------------------------------------------
	// | Author: 微尘 <yicmf@qq.com>
	// +----------------------------------------------------------------------

	namespace app\controller\ucenter\admin;

	use app\common\controller\Base;
	use app\pay\model\UserBalanceCash;
	use app\model\ucenter\User as UserModel;
	use app\model\ucenter\UserAuth;

	class Home extends Base
	{


		public function right()
		{
            return  '';
			// 显示页面
			return $this->fetch('ucenter/admin/home/right');
		}
		public function overview()
		{
            return  [];
			$overview[] = [
				'title' => '新增用户（累积）',
				'number' => UserModel::where('status',1)->whereTime('create_time','today')->count().'('.UserModel::where('status',1)->count().')',
			];
			return $overview;
		}

		/**
		 * 快捷方式
		 * @return array
		 */
		public function quick()
		{
			return [];
		}

		/**
		 * 待办事项
		 * @return array
		 */
		public function wait()
		{

//			$this->assign('auth', UserAuth::where('status',0)->count());
//			$wait[] = [
//				'title'=>'实名认证',
//				'link'=>'ucenter/admin/UserAuth/index',
//				'number'=>UserAuth::where('status',0)->count(),
//			];
            $wait = [];
			return $wait;
		}


		public function left()
		{
            return '';
			$result = UserModel::field('DATE_FORMAT(create_time,"%Y%m%d") days,count(id)  num')->whereTime('create_time', date('Y-m-d', strtotime('-7 days')))->group('days')->select();
			$result2 = UserModel::where('status', 5)
				->field('DATE_FORMAT(last_active_time,"%Y%m%d") days,count(id)  num')->whereTime('last_active_time', date('Y-m-d', strtotime('-7 days')))->group('days')->select();
			$x_time = [];
			$series = [];
			$series2 = [];
			for ($i = 7; $i >= 0; $i--) {
				$day = date('Ymd', strtotime(date('Y-m-d', strtotime('-' . $i . ' days'))));
				$num = 0;
				$x_time[] = $day;
				foreach ($result as $item) {
					if ($item['days'] == $day) {
						$num = $item['num'];
						break;
					}
				}
				$series[] = $num;
				$num = 0;
				foreach ($result2 as $item) {
					if ($item['days'] == $day) {
						$num = $item['num'];
						break;
					}
				}
				$series2[] = $num;
			}
			$this->assign('x_time', $x_time);
			$this->assign('series', $series);
			$this->assign('series2', $series2);


			// 显示页面
			return $this->fetch('ucenter/admin/home/left');
		}

	}
